<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<div class="setp_main">
	<table class="table" style="width: 100%" cellpadding="0" cellspacing="0">
		<tr>
			<td>
				<table style="width: 100%" cellpadding="0" cellspacing="0">
					<tr class="title">
						<td width="300px"><span class="stress">*</span>&nbsp;服务：</td>
						<td><span class="stress">*</span>&nbsp;货主运输条款：</td>
					</tr>
					<tr>
						<td>
							<s:select id="expressType" name="work.expressType" list="#{0:'包裹',1:'文件'}" 
								headerKey="" headerValue="请选择" listKey="key" listValue="value" value="work.expressType"></s:select>
						</td>
						<td>
							<s:select id="expressPayment1" name="work.expressPayment1" list="#{0:'寄件人',1:'收件人',2:'第三方'}" 
								headerKey="" headerValue="请选择付款方式" listKey="key" listValue="value" value="work.expressPayment1"></s:select>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table style="width: 100%; table-layout: fixed;" cellpadding="0" cellspacing="0">
					<tr class="title">
						<td width="185px"><span class="stress">*</span>&nbsp;件数（包装）：</td>
						<td width="144px"><span class="stress">*</span>&nbsp;实际重量：</td>
						<td width="144px">&nbsp;&nbsp;体积：</td>
						<td width="143px"><span class="stress">*</span>&nbsp;体积重量：</td>
						<td>&nbsp;&nbsp;海关申报价值：</td>
					</tr>
					<tr>
						<td>
							<input type="text" id="expressQuantity" name="work.expressQuantity" v_tips="notnull,ni" value="<s:property value="work.expressQuantity" />" class="input_s"/>
							<s:select id="expressPackageType" name="work.expressPackageType.id" cssClass="input_s" cssStyle="margin-left: -5px;margin-right: -5px;" list="#request.allPackageType" listKey="id" listValue="name" value="work.expressPackageType.id"></s:select>
						</td>
						<td style="line-height: 42px;">
							<input type="text" id="expressWeight" name="work.expressWeight" v_tips="notnull,number" class="input_s" value="<s:property value="work.expressWeight"/>"/>KGS
						</td>
						<td style="line-height: 42px;">
							<input type="text" id="expressVolume" name="work.expressVolume" v_tips="nullable,number" class="input_s" value="<s:property value="work.expressVolume"/>"/>CBM
						</td>
						<td style="line-height: 42px;">
							<input type="text" id="expressVolumeWeight" name="work.expressVolumeWeight" v_tips="notnull,number" class="input_s" value="<s:property value="work.expressVolumeWeight"/>"/>KGS
						</td>
						<td style="line-height: 42px;">
							<input type="text" id="expressValue" name="work.expressValue" class="input_s" value="<s:property value="work.expressValue"/>"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr class="title"><td><span class="stress">*</span>&nbsp;货物说明：</td></tr>
		<tr>
			<td>
				<textarea id="expressDetail" name="work.expressDetail" v_tips="notnull" class="input_xl jNiceTextarea"><s:property value="work.expressDetail"/></textarea>
			</td>
		</tr>
		<tr class="title"><td><span class="stress">*</span>&nbsp;寄件人：</td></tr>
		<tr>
			<td>
				<textarea id="expressShipper" name="work.expressShipper" v_tips="notnull" class="input_xl jNiceTextarea"><s:property value="work.expressShipper"/></textarea>
			</td>
		</tr>
		<tr class="title"><td><span class="stress">*</span>&nbsp;收件人：</td></tr>
		<tr>
			<td>
				<textarea id="expressConsignee" name="work.expressConsignee" v_tips="notnull" class="input_xl jNiceTextarea"><s:property value="work.expressConsignee"/></textarea>
			</td>
		</tr>
	</table>
</div>
<script>
	var preErrorId = [];
	function validateForm(){
		var errorId = [];
		if($('#expressType').val() == ''){
			errorId[errorId.length] = 'expressType';
		}
		if($('#expressPayment1').val() == ''){
			errorId[errorId.length] = 'expressPayment1';
		}
		if($('#expressQuantity').val().trim().length == 0){
			errorId[errorId.length] = 'expressQuantity';
		}
		if($('#expressPackageType').val() == '' || $('#expressPackageType').val() == 0){
			errorId[errorId.length] = 'expressPackageType';
		}
		if($('#expressWeight').val().trim().length == 0){
			errorId[errorId.length] = 'expressWeight';
		}
		if($('#expressVolumeWeight').val().trim().length == 0){
			errorId[errorId.length] = 'expressVolumeWeight';
		}
		if($('#expressDetail').val().trim().length == 0){
			errorId[errorId.length] = 'expressDetail';
		}
		if($('#expressShipper').val().trim().length == 0){
			errorId[errorId.length] = 'expressShipper';
		}
		if($('#expressConsignee').val().trim().length == 0){
			errorId[errorId.length] = 'expressConsignee';
		}
		for(i=0; i<preErrorId.length; i++){
			normalCssJNice(preErrorId[i]);
		}
		if(errorId.length > 0){
			preErrorId = errorId;
			for(i=0; i< errorId.length; i++){
				errorCssJNice(errorId[i]);
			}
			return;
		}
		var params = $("#workForm").serialize();
		$.post('cts/workStep2?save=true',params,function(result){
			if(result.trim() == 'null'){
				alert('订单不存在或已经被删除');
			}else if(result.trim() == 'status5'){
				alert('该订单已归档');
			}else if(result.trim() == 'ok'){
				nextStep();
			}else{
				alert('保存失败');
			}
		})
	}
</script>